package com.cxyjy.common.util;

/**
 * @Author: jony
 * @Date : 2024/11/6 09:45
 * @VERSION v1.0
 */
public class ResultUtil {
    /**
     * 成功
     *
     * @param data
     * @param <T>
     * @return
     */
    public static <T> JResponse<T> success(T data) {
        return new JResponse<>(200, data);
    }

    public static JResponse justSuccess() {
        return new JResponse(200, "success", null);
    }

    /**
     * 成功
     *
     * @param data
     * @return
     */
    public static JResponse success(int data) {
        return new JResponse(200, data);
    }

    /**
     * 失败
     *
     * @param resultCode
     * @return
     */
    public static JResponse error(ResultCode resultCode) {
        return new JResponse<>(resultCode.getCode(),  resultCode.getMessage());
    }

    public static JResponse error(String message){
        return new JResponse<>(500,message);
    }

    /**
     * 失败
     *
     * @param resultCode
     * @return
     */
    public static JResponse error(ResultCode resultCode, String message) {
        return new JResponse<>(resultCode.getCode(), resultCode.getMessage());
    }

    /**
     * 失败
     *
     * @param code
     * @return
     */
    public static JResponse error(int code, String message) {
        return new JResponse<>(code, message, null);
    }

}
